<html>
 <head>
    <meta name="layout" content="main"/>
    <r:require modules="datePicker, ventaSemana, typeAhead"/>
 </head>
 <body>
  <form method="post">
   <div class="row-fluid">
	   <div class="span5">
	    <ul>
	      <li><a href="${createLink(uri:'/')}">HOME</a></li>
	      <li><g:link action="list" >Lista de Ventas</g:link></li>      
	    </ul>
	   </div> 
       <div class="span7">
        <g:render template="form"/>   
       </div>
   </div>
    <div class="row-fluid">
      <div class="span4">
	    <h6>Buscador de Artículos:</h6>
	    <input id="searchTxt" type="text" placeholder="Buscar" data-provide="typeahead" 
		       data-items="20" autocomplete="off" 
		       onblur="ventaController.obtainIdArtSelected()" >
      </div>
    </div>
    <g:render template="itemForm"/>   
    <g:hiddenField name="ventaId" value="${ventaSemanaInstance.id}"/>
    <input id="addItem" type="button" name="AddItem" value="Add Item" onclick="ventaController.addItemFinal();"/>
    
	<table id="itemsVendidos" class="table table-striped table-bordered dataTable">
	   <thead>
	      <tr>
	         <th>Id</th>
	         <th>Código</th>	      
	         <th>Descripción</th>       
	         <th>Cantidad</th>
	         <th>Costo</th>	          
	         <th>Precio</th>	         
	         <th>Cobrado</th> 	         	           
	      </tr>
	   </thead>
	   <tbody>
	    <g:each var="item" in="${itemVentaListInstance}">
	      <tr id="${item.id}">
	        <td>${item.id}</td>
	        <td>${item.codigoArticulo}</td>
	        <td>${item.descripcion}</td>
	        <td>${item.cantidad}</td>
	        <td>${item.costo}</td>     
	        <td>${item.precio}</td>	   
	        <td>${item.cobrado}</td>
	        <td><input type="button" value="Borrar" onclick="ventaController.borrarItemVenta(${item.id})"/></td>	
	      </tr>
	    </g:each>
	   </tbody>
	</table>    
    <fieldset class="forms">
     </fieldset>
     <fieldset class="buttons">
       <g:actionSubmit action="update" value="Guardar" class="save"/>
       <g:actionSubmit action="delete" value="Borrar" class="delete" />
     </fieldset>
   </form>
 </body>
 </html>